const mongoose = require('mongoose')
const { preSave } = require('../utils')

const LogSchema = new mongoose.Schema({
    user: {
        account: String,
        id: String,
    },
    request: {
        method: String,
        url: String,
        status: Number,
    },
    startTime: Number,
    endTime: Number,
    meta: {
        createAt: {
            type: Number,
            default: (new Date()).getTime(),
        },
        updateAt: {
            type: Number,
            default: (new Date()).getTime(),
        },
    },
})

LogSchema.pre('save', preSave)
module.exports = LogSchema
